Skip to content

fix: retry Vault hook after addons enable#2995

Merged
tastybento merged 1 commit into
developfrom
fix/retry-vault-hook-after-addons
Jun 21, 2026
Merged

fix: retry Vault hook after addons enable#2995
tastybento merged 1 commit into
developfrom
fix/retry-vault-hook-after-addons

Conversation

@tastybento

Copy link
Copy Markdown
Member

Problem

BentoBox registers its VaultHook during early hooks (BentoBoxHookRegistrar.registerEarlyHooks()), which runs before addonsManager.enableAddons(). At that point no economy provider may be registered with Bukkit's ServicesManager yet, so VaultHook.hook() returns false. HooksManager.registerHook() only stores hooks whose hook() succeeds, so a failed Vault hook is discarded entirely and getVault() returns empty.

This is a problem for addons that provide a Vault economy in their own onEnable() — e.g. InvSwitcher, which registers a per-world Economy provider so each game world has its own balance. Because BentoBox already gave up on Vault, getVault() stays empty even though a perfectly good economy now exists, and economy-dependent addons such as Bank disable themselves with "Vault is required".

Fix

Re-attempt the Vault hook once, right after enableAddons(), via a new BentoBoxHookRegistrar.registerVaultHookIfNeeded() (no-op if Vault is already hooked). Any economy an addon registered during enable is now picked up.

This is a minimal, general safety net — it helps any addon that registers an economy in onEnable, not just InvSwitcher.

Notes

  • Addons that consult getVault() during their own onEnable (like Bank) still need to either enable after the economy provider or retry the hook themselves; a companion PR to Bank does the latter. This PR fixes the general BentoBox-side gap.
  • Branched from develop.

🤖 Generated with Claude Code

BentoBox hooks Vault during early hooks, before addons are enabled. An
addon may register a Vault economy provider in its own onEnable (e.g.
InvSwitcher, which provides per-world balances), after that early attempt
already failed for lack of any economy. A failed hook is discarded by
HooksManager, so getVault() stayed empty even though an economy now
exists - leaving economy-dependent addons (e.g. Bank) unable to start.

Re-attempt the Vault hook once after enableAddons() so an economy
provided by an addon is picked up.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@tastybento tastybento merged commit d580fb2 into develop Jun 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant